package com.isunland.managesystem.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BasePagerActivity;
import com.isunland.managesystem.entity.Task;

public class TaskPagerActivity extends BasePagerActivity {

  //public static final String EXTRA_TASK_ID = "com.isunland.managesystem.Activity.TASK_ID";
  public static final String EXTRA_TASK_CONTENT = "com.isunland.managesystem.Activity.TASK_CONTENT";
  public Task mtaskContent;
  //public String task_key = "";
  int[] mTitleId = {
      R.string.form_detail, R.string.flow_chat, R.string.examine_history
  };

  @Override protected Fragment createFragmentOne() {
    boolean isToDo = mtaskContent != null && mtaskContent.isToDo();
    Fragment mFormDetailFragment;
    if (isToDo) {
      mFormDetailFragment = ToDoFormDetailFragment.newInstance(mtaskContent);
    } else {
      mFormDetailFragment = FormDetailFragment.newInstance(mtaskContent);
    }
    return mFormDetailFragment;
  }

  @Override protected Fragment createFragmentTwo() {
    return FlowChatFragment.newInstance(mtaskContent);
  }

  @Override public Fragment createFragmentThree() {
    return ExamineHistoryFragment.newInstance(mtaskContent);
  }

  @Override protected int[] createTitle() {
    return mTitleId;
  }

  @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle arg0) {
    mtaskContent = (Task) getIntent().getSerializableExtra(EXTRA_TASK_CONTENT);
    super.onCreate(arg0);
  }

  //@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  //  if (resultCode != Activity.RESULT_OK) {
  //    return;
  //  }
  //  if (requestCode == 1) {
  //    setResult(Activity.RESULT_OK);
  //    this.finish();
  //  }
  //  super.onActivityResult(requestCode, resultCode, data);
  //}
}
